import React, { Component } from 'react'
import Home from './Home'

// 1. 创建一个Context
import ThemeContext from './contexts/theme-context'
import UserContext from './contexts/user-context'

export class App extends Component {
  constructor() {
    super()
    this.state = {
      info: {
        name: '李四',
        age: 20
      }
    }
  }
  render() {
    const { info } = this.state
    return (
      <div>
        {/* 1. 给Home传递数据 */}
        {/* <Home name={'张三'} age={14}></Home>*/}

        {/* 2. 通过Context给组件传递数据 */}
        <ThemeContext.Provider value={{color: 'red', fontSize: 30}}>
        <UserContext.Provider value={{message:'你好'}}>
          <Home {...info}></Home> 
        </UserContext.Provider>
        </ThemeContext.Provider>
      </div>
    )
  }
}

export default App